odoo.define('date_format_year', function (require) {
    "use strict";
    var fieldRegistry = require('web.field_registry');
    var FieldDate = require('web.basic_fields').FieldDate
    const DateFormatYear = FieldDate.extend({
        description: "年份",
        supportedFieldTypes: ['date', 'datetime'],
        _renderReadonly() {
            if (this.value !== false) {
                var text = this._formatValue(this.value, 'date')
                if (text.indexOf("年")!= -1) {
                    var year = text.substring(0, text.indexOf("年") + 1)
                    this.$el.text(year)
                }
            }
        },
    });

    fieldRegistry.add('date_year', DateFormatYear);

    return {
        DateFormatYear: DateFormatYear,
    };

})